﻿using MediatR;
using T.Contract.Domain.T.Contract.Model;
using T.Contract.Read.API.Application.Command.ContractCommand;
using T.Contract.Repository.Interface;

namespace T.Contract.Read.API.Application.CommandHandlers.ContractHandler
{
    /// <summary>
    /// 显示货主合同审批记录
    /// </summary>
    public class ContractListCommandHander : IRequestHandler<ContractListCommand, List<HApproval>>
    {
        private readonly IHApproval _happroval;
        public ContractListCommandHander(IHApproval happroval)
        {
            _happroval = happroval;
        }
        public async Task<List<HApproval>> Handle(ContractListCommand request, CancellationToken cancellationToken)
        {
            var HList= await _happroval.GetAsync(d => !d.IsDeleted &&d.CompanyID==request.CompanyID&& d.ContractId == request.ContractId);
            return HList.OrderByDescending(d => d.CreatedBy).ToList();
        }
    }
}
